﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WF.Model;
using WF.DAL;

namespace WF.BusinessObject
{
    public class WF_ApplyInstanceDetail : BOBase<WF_ApplyInstanceDetailEntity, DAL.WF_ApplyInstanceDetail>
    {
        #region 构造函数

        public WF_ApplyInstanceDetail() : base() { }
        public WF_ApplyInstanceDetail(WFDBDataContext DataContext) : base(DataContext) { }
        #endregion

        #region 实现基类abstract方法
        /// <summary>
        /// 实现基类的GetById abstract方法
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public override WF_ApplyInstanceDetailEntity GetById(string ID)
        {
            var obj = DataContext.WF_ApplyInstanceDetails.SingleOrDefault(o => o.DetailID == ID);
            return new WF_ApplyInstanceDetailEntity(obj);
        }
        #endregion

        #region Public 方法
        public List<WF_ApplyInstanceDetailEntity> GetAll()
        {
            var target = DataContext.WF_ApplyInstanceDetails.ToList();
            List<WF_ApplyInstanceDetailEntity> result = new List<WF_ApplyInstanceDetailEntity>();
            foreach (var item in target)
            {
                result.Add(new WF_ApplyInstanceDetailEntity(item));
            }
            return result;
        }
        #endregion

        #region WF_ApplyInstanceDetail
        /// <summary>
        /// Get All WF_ApplyInstanceDetailEntity
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool GetAllWF_ApplyInstanceDetailEntity(out List<WF_ApplyInstanceDetailEntity> result)
        {
            var target = DataContext.WF_ApplyInstanceDetails.ToList();
            result = new List<WF_ApplyInstanceDetailEntity>();
            foreach (var item in target)
            {
                result.Add(new WF_ApplyInstanceDetailEntity(item));
            }

            return true;
        }

        ///// <summary>
        /////  GetWF_ApplyInstanceDetailEntityById
        ///// </summary>
        ///// <param name="p"></param>
        ///// <param name="result"></param>
        ///// <returns></returns>
        //public bool GetWF_ApplyInstanceDetailEntityById(string p, out WF_ApplyInstanceDetailEntity result)
        //{
        //    DAL.WF_ApplyInstanceDetail systemSetting = DataContext.WF_ApplyInstanceDetails.SingleOrDefault(obj => obj.DetailID == p);
        //    result = new WF_ApplyInstanceDetailEntity(systemSetting);

        //    return true;
        //}

        ///// <summary>
        ///// Add
        ///// </summary>
        ///// <param name="wF_ApplyInstanceDetailEntity"></param>
        ///// <returns></returns>
        //public bool Add(WF_ApplyInstanceDetailEntity wF_ApplyInstanceDetailEntity)
        //{
        //    DAL.WF_ApplyInstanceDetail wf_appInstanceDetail = new DAL.WF_ApplyInstanceDetail();
        //    if (wF_ApplyInstanceDetailEntity.ID == null || wF_ApplyInstanceDetailEntity.ID == string.Empty)
        //        wf_appInstanceDetail.DetailID = System.Guid.NewGuid().ToString();
        //    else
        //        wf_appInstanceDetail.DetailID = wF_ApplyInstanceDetailEntity.ID;
        //    wf_appInstanceDetail.ApplyID = wF_ApplyInstanceDetailEntity.ApplyID;
        //    wf_appInstanceDetail.BizDataID = wF_ApplyInstanceDetailEntity.BizDataID;

        //    DataContext.WF_ApplyInstanceDetails.InsertOnSubmit(wf_appInstanceDetail);
        //    DataContext.SubmitChanges();

        //    return true;
        //}
        ///// <summary>
        ///// update
        ///// </summary>
        ///// <param name="wF_ApplyInstanceDetailEntity"></param>
        ///// <returns></returns>
        //public bool Update(WF_ApplyInstanceDetailEntity wF_ApplyInstanceDetailEntity)
        //{
        //    DAL.WF_ApplyInstanceDetail wfAppInstanceDetail = DataContext.WF_ApplyInstanceDetails.SingleOrDefault(obj => obj.DetailID == wF_ApplyInstanceDetailEntity.ID);
        //    if (wfAppInstanceDetail == null)
        //        return false;

        //    wfAppInstanceDetail.ApplyID = wF_ApplyInstanceDetailEntity.ApplyID;
        //    wfAppInstanceDetail.BizDataID = wF_ApplyInstanceDetailEntity.BizDataID;

        //    DataContext.SubmitChanges();

        //    return true;
        //}

        ///// <summary>
        ///// delete
        ///// </summary>
        ///// <param name="p"></param>
        ///// <returns></returns>
        //public bool DeleteWF_ApplyInstanceDetailEntity(string p)
        //{
        //    DAL.WF_ApplyInstanceDetail wfAppInstanceDetail = DataContext.WF_ApplyInstanceDetails.SingleOrDefault(obj => obj.ApplyID == p);
        //    if (wfAppInstanceDetail != null)
        //    {
        //        DataContext.WF_ApplyInstanceDetails.DeleteOnSubmit(wfAppInstanceDetail);
        //        DataContext.SubmitChanges();
        //    }

        //    return true;
        //}
        #endregion
    }
}
